
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>right</title>
    <link rel="stylesheet" href="./css/main.css">
    <link rel="stylesheet" href="./css/style.css">
    <link rel="stylesheet" href="./css/animate.css">
    <link rel="stylesheet" href="./css/base.css">
    <link rel="stylesheet" href="./css/bootstrap.css">
    <link rel="stylesheet" href="./css/normalize.css">
    <script src="./js/check.js"></script>
    <script>
        function addProduct(){
            window.location.href="./addProduct.php";
        }
        function deletePro(){
            var msg="确认删除该商品吗？";
            if(confirm(msg)){
                return true;
            }else{
                return false;
            }
        }
    </script>
</head>
<body style="background: #252c35;height: 100%">
<div class="mScroll">
    <div class="container">
        <div class="jsbg">
            <div class="col-lg-12 mxlength">
                <h5>查询条件</h5>
                <form action="./right.php?a=product" method="post" name="productId">
                    <table class="shops container-fluid spow">
                        <tr>
                            <td>商品编号：<input type="text" name="productId" value="<?=$productId?>"> </td>
                            <td>商品分类：
                                <select name="category" >
                                    <option value="" selected>-----选择商品类型-----</option>
                                    <?php if(is_array($category)): foreach($category as $cate):?>
                                    <option value="<?=$cate['id']?>" <?= ($cate['id']==$cateId)?'selected':'' ?> ><?= $cate['category'] ?></option>
                                    <?php endforeach; endif;?>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td >商品名称：<input type="text" name="productName" value="<?=$name?>"></td>
                            <td id="shname">价格区间（元）：<input type="text" name="minPrice" onkeyup="num(this)" value="<?=$maxPrice?>"> - <input type="text" name="maxPrice" onkeyup="num(this)" value="<?=$minPrice?>"></td>
                        </tr>
                        <div class="btn-group shop-btn" role="group" aria-label="Basic example">
                            <button type="submit" class="btn btn-primary">查询</button>
                            <button type="reset" class="btn btn-primary">重置</button>
                            <button type="button" class="btn btn-primary" onclick="addProduct()">添加</button>
                        </div>
                    </table>

                </form>
            </div>
            <div class="col-lg-12 mxlength bord">
                <h5>商品列表</h5>
                <form action="" method="post">
                    <table class=" shopp container-fluid">
                        <tr>
                            <th>商品编号</th>
                            <th>商品名称</th>
                            <th>商品价格</th>
                            <th>商品数量</th>
                            <th>商品状态</th>
                            <th>商品分类</th>
                            <th>商品描述</th>
                            <th>编辑</th>
                            <th>删除</th>
                        </tr>
                        <?php if(is_array($products)):foreach($products as $product):?>
                        <tr>
                            <td><?=$product['id']?></td>
                            <td><?=$product['name']?></td>
                            <td><?=$product['price']?></td>
                            <td><?=$product['pnum']?></td>
                            <td><?=($product['status']==0)?'有效':'下架'?></td>
                            <td><?=$product['category']?></td>
                            <td><?=$product['description']?></td>
                            <td>
                                <a href="./addProduct.php?id=<?=$product['id']?>" target="rightframe"><img src="./img/i_edit.gif" alt=""> </a>
                            </td>
                            <td>
                                <a href="./delProduct.php?id=<?=$product['id']?>" target="rightframe" onclick="javascript:return deletePro()"><img src="./img/i_del.gif" alt=""></a>
                            </td>
                        </tr>
                        <?php endforeach; endif; ?>

                    </table>
                </form>
            </div>

        </div>
    </div>
</div>
<script type="text/javascript" src="./js/bootstrap.bundle.js"></script>
<script type="text/javascript" src="./js/jquery-3.6.0.min.js"></script>
<script type="text/javascript" src="./js/style.js"></script>

</body>

</html>
